<!DOCTYPE html>
<html lang="en">
<head>
<!-- <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.2.0/css/bootstrap-grid.css" rel="stylesheet"> -->
	<link href="../vendor/bootstrap-grid.css" rel="stylesheet">

<meta charset="utf-8"/>
<link rel="apple-touch-icon" sizes="76x76" href="../assets/img/favicon.ico">
<link rel="icon" type="image/png" href="../assets/img/favicon.ico">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no' name='viewport'/>



<!-- Font Awesome Icons -->

<!-- Main CSS -->
<link href="../assets/css/main.css" rel="stylesheet"/>

<!-- Animation CSS -->
<link href="../vendor/aos.css" rel="stylesheet"/>
<link href="../assets/layui/css/layui.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="../assets/font/iconfont.css" />
	<style>




	</style>
</head>

<body>


<main class="container">

<!--------------------------------------
PRICING
--------------------------------------->
<section class="pt-4 pb-5">
<div class="col-md-12" id="probation">
	<form id="form1"  class="layui-form"  lay-filter="applyMadeForm">
		<div class="row form-group">
			<div class="col">
				<p>评分</p>
				<div id="starsBox" class="form-control" style="border: 0;"></div>
			</div>
		</div>
		<div class="row form-group">
			<div class="col">
				<label>评价描述</label>
				<textarea class="form-control" rows="3" placeholder="请填写评价描述" name="assessInfo"></textarea>
			</div>
		</div>

		<button type="submit" class="btn btn-cyan btn-round text-white submitBtn" style="float: right;">提交</button>
	</form>
</div>
</section>



<!--------------------------------------
JAVASCRIPTS
--------------------------------------->
<script src="../vendor/jquery.min.js" type="text/javascript"></script>
<script src="../assets/layui/layui.js" type="text/javascript"></script>
<script src="../js/tool.js" type="text/javascript"></script>



<script>
	$(function () {
		var scoreVal = 0;
		//星星
		layui.rate.render({
		    elem: '#starsBox',
			value: scoreVal,
			theme: '#009688'
		});
		layui.rate.render({
		  elem: '#starsBox',
		  choose: function(value){
		    scoreVal = value;
		  }
		});
		//提交
		$("body").on("click",'.submitBtn',function (e){
			e.preventDefault();
			var data1 = layui.form.val("applyMadeForm");
			console.log(data1,'data1')
			data1.productId = +parent.window.dataProductId;
			data1.id = parent.window.dataId
			data1.userId = +sessionStorage.getItem('UserId');
			data1.assessValue = scoreVal;
			console.log(data1,'data1')

			$.ajax({
       			timeout:30000,
				url: window.Http + "/orderProduct/evaluate",
				type: 'POST',
				headers: {
					'Authorization': "Bearer " + sessionStorage.getItem('Token')
				},
				data: data1,
				contentType:"application/x-www-form-urlencoded\n",
				success: function (res) {
					if (res.code === 200) {
						layer.msg("评价成功！");
						setTimeout(function(){
							let index = parent.layer.getFrameIndex(window.name);
							//再执行关闭
							parent.layer.close(index);
							//parent.layer.close(1); //再执行关闭
						},1000)
					}else{
						layer.msg(res.msg);
					}
				}
			})

		})


	})
</script>

</body>
</html>
